# version:1
FROM python:3.9-alpine

WORKDIR /home/app
COPY requirements.txt  /home/app

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk --no-cache add gcc libc-dev  zlib-dev jpeg-dev libjpeg  musl-dev libffi-dev
RUN apk --no-cache add curl vim busybox-extras 
RUN apk --no-cache add openldap-dev
RUN apk --no-cache add python3-dev

RUN pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com --upgrade pip
#RUN pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com -r requirements.txt
RUN pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com Django==3.2.9 djangorestframework==3.12.4 djangorestframework-jwt
RUN pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com django-cors-headers Pillow  requests
RUN pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com python3-ldap 
RUN pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com django-auth-ldap
RUN pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com django-simpleui


COPY . /home/app
RUN rm -rf /home/app/env /root/.cache/pip/  /var/cache/apk/*

EXPOSE 8000
CMD [ "python", "./manage.py", "runserver", "0.0.0.0:8000"]


# docker build -t lghost/ldap-password:latest . # build images
# docker push lghost/ldap-password:latest # 推送到dockerhub
